﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using VR_MVC.Models;

namespace VR_MVC.Controllers
{
    public class VoterMergeFilesController : Controller
    {
        private VoterRegistrationEntities1 db = new VoterRegistrationEntities1();

        // GET: VoterMergeFiles
        public ActionResult Index()
        {
            var voterMergeFiles = db.VoterMergeFiles.Include(v => v.VoterMergeFileDetail);
            return View(voterMergeFiles.ToList());
        }

        // GET: VoterMergeFiles/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            VoterMergeFile voterMergeFile = db.VoterMergeFiles.Find(id);
            if (voterMergeFile == null)
            {
                return HttpNotFound();
            }
            return View(voterMergeFile);
        }

        // GET: VoterMergeFiles/Create
        public ActionResult Create()
        {
            ViewBag.VoterFileID = new SelectList(db.VoterMergeFileDetails, "VoterFileID", "VoterFileID");
            return View();
        }

        // POST: VoterMergeFiles/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "VoterFileID,VOTER_ID,COUNTY,LAST_NAME,FIRST_NAME,MIDDLE_NAME,NAME_SUFFIX,VOTER_NAME,PRECINCT_NAME,HOUSE_NUM,HOUSE_SUFFIX,PRE_DIR,STREET_NAME,STREET_TYPE,POST_DIR,UNIT_TYPE,UNIT_NUM,ADDRESS_NON_STD,RESIDENTIAL_ADDRESS,RESIDENTIAL_CITY,RESIDENTIAL_STATE,RESIDENTIAL_ZIP_CODE,RESIDENTIAL_ZIP_PLUS,EFFECTIVE_DATE,REGISTRATION_DATE,STATUS,STATUS_REASON,BIRTH_YEAR,GENDER,PRECINCT,PARTY,MAILING_ADDRESS_1,MAILING_ADDRESS_2,MAILING_ADDRESS_3,MAILING_CITY,MAILING_STATE,MAILING_ZIP_CODE,MAILING_ZIP_PLUS,MAILING_COUNTRY")] VoterMergeFile voterMergeFile)
        {
            if (ModelState.IsValid)
            {
                db.VoterMergeFiles.Add(voterMergeFile);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.VoterFileID = new SelectList(db.VoterMergeFileDetails, "VoterFileID", "VoterFileID", voterMergeFile.VoterFileID);
            return View(voterMergeFile);
        }

        // GET: VoterMergeFiles/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            VoterMergeFile voterMergeFile = db.VoterMergeFiles.Find(id);
            if (voterMergeFile == null)
            {
                return HttpNotFound();
            }
            ViewBag.VoterFileID = new SelectList(db.VoterMergeFileDetails, "VoterFileID", "VoterFileID", voterMergeFile.VoterFileID);
            return View(voterMergeFile);
        }

        // POST: VoterMergeFiles/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "VoterFileID,VOTER_ID,COUNTY,LAST_NAME,FIRST_NAME,MIDDLE_NAME,NAME_SUFFIX,VOTER_NAME,PRECINCT_NAME,HOUSE_NUM,HOUSE_SUFFIX,PRE_DIR,STREET_NAME,STREET_TYPE,POST_DIR,UNIT_TYPE,UNIT_NUM,ADDRESS_NON_STD,RESIDENTIAL_ADDRESS,RESIDENTIAL_CITY,RESIDENTIAL_STATE,RESIDENTIAL_ZIP_CODE,RESIDENTIAL_ZIP_PLUS,EFFECTIVE_DATE,REGISTRATION_DATE,STATUS,STATUS_REASON,BIRTH_YEAR,GENDER,PRECINCT,PARTY,MAILING_ADDRESS_1,MAILING_ADDRESS_2,MAILING_ADDRESS_3,MAILING_CITY,MAILING_STATE,MAILING_ZIP_CODE,MAILING_ZIP_PLUS,MAILING_COUNTRY")] VoterMergeFile voterMergeFile)
        {
            if (ModelState.IsValid)
            {
                db.Entry(voterMergeFile).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.VoterFileID = new SelectList(db.VoterMergeFileDetails, "VoterFileID", "VoterFileID", voterMergeFile.VoterFileID);
            return View(voterMergeFile);
        }

        // GET: VoterMergeFiles/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            VoterMergeFile voterMergeFile = db.VoterMergeFiles.Find(id);
            if (voterMergeFile == null)
            {
                return HttpNotFound();
            }
            return View(voterMergeFile);
        }

        // POST: VoterMergeFiles/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(string id)
        {
            VoterMergeFile voterMergeFile = db.VoterMergeFiles.Find(id);
            db.VoterMergeFiles.Remove(voterMergeFile);
            db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
